package com.leetcode.no830;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Solution {
    public List<List<Integer>> largeGroupPositions(String s) {
        List<List<Integer>> res = new LinkedList<>();


        int n = s.length();

        if (n < 2) {
            return res;
        }


        for (int i = 0; i <= n - 2; ) {
            char c = s.charAt(i);
            System.out.println(c);

            int currentIndex = i;
            int counter = 1;

            i++; // 移动到下一个字母
            while (s.charAt(i) == c) {
                counter++;
                i++;
                if (i == n ) {
                    break;
                }
            }
            System.out.println(counter);
            if (counter >= 3) {
                List<Integer> a_res = new LinkedList<>();
                a_res.add(currentIndex);
                a_res.add(i - 1);
                res.add(a_res);
            }
        }

        return res;
    }

    public static void main(String[] args) {
        Solution s1 = new Solution();
//        String s = "abcdddeeeeaabbbcd";
        String s = "aaa";
        System.out.println(s1.largeGroupPositions(s));
    }
}
